require_dependency "login_system" 
require_dependency "acl_system" 

# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
	#include LoginSystem
	include ACLSystem
	model :account
	model :addressSalePaper
     
    protected
    def redirect_to_success(msg = nil)
		flash[:notice] = msg if msg
		redirect_to(:controller=>'common_action',:action=>'action_success')
	end
	
	def redirect_to_failure(msg = '操作失败')
		flash[:notice] = msg if msg
		redirect_to(:controller=>'common_action',:action=>'action_failure')
	end
	
	def formatSaleNum(num,length)
		retNum = num.to_s
		if num.to_s.length < length
			(length-num.to_s.length).times do |i|
				retNum.insert(0,'0')
			end
		end
		retNum
	end
	
	def buildMenu(varmodule = nil)
		tmpRights = @session[:account].role.rights
		@rights = Array.new
		tmpRights.each do |right|
			if right.module.eql? varmodule
				@rights<<right
			end
		end
		@rights
	end
end